<html>
<head>
<title>getdirentry</title>
<body bgcolor=#ffffff>
<h2 align=center>getdirentry</h2>
<h4 align=center>OS/161 Reference Manual</h4>

<h3>Name</h3>
getdirentry - read filename from directory

<h3>Library</h3>
Standard C Library (libc, -lc)

<h3>Synopsis</h3>
#include &lt;unistd.h&gt;<br>
<br>
int<br>
getdirentry(int <em>fd</em>, char *<em>buf</em>, size_t <em>buflen</em>);

<h3>Description</h3>

getdirentry retrieves the next filename from a directory referred to
by the file handle <em>filehandle</em>. The name is stored in
<em>buf</em>, an area of size <em>buflen</em>. The length of of the
name actually found is returned.
<p>

Note: this call behaves like read() - the name stored in <em>buf</em>
is not null-terminated.
<p>

Which filename is the "next" is chosen based on the seek pointer
associated with the file handle. The meaning of the seek pointer on a
directory is defined by the filesystem in use and should not be
interpreted - the only ways in which <A HREF=lseek.html>lseek</A>
should be used are with SEEK_SET and an offset previously returned by
lseek, or with any of SEEK_SET, SEEK_CUR, or SEEK_EOF with an offset
of 0.
<p>

<h3>Return Values</h3>
On success, getdirentry returns the length of the name transferred.
On error, -1 is returned, and <A HREF=errno.html>errno</A> is set
according to the error encountered.

<h3>Errors</h3>

<blockquote><table width=90%>
<td width=10%>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>EBADF</td>		<td><em>fd</em> is not a valid file handle.</td></tr>
<tr><td>ENOTDIR</td>	<td><em>fd</em> does not refer to a directory.</td></tr>
<tr><td>EIO</td>		<td>A hard I/O error occurred.</td></tr>
<tr><td>EFAULT</td>		<td><em>buf</em> points to an invalid address.</td></tr>
</table></blockquote>

</body>
</html>
